home *** CD-ROM | disk | FTP | other *** search
- unit CalConstants;
- interface
- uses sysutils;
- (*
-
- These constants and much of the code logic comes from Dr. John
- Stockton's MJD_DATE.PAS. He has an excellent site at
- http://www.merlyn.demon.co.uk jrs@merlyn.demon.co.uk.
-
- Any errors in the changes I've made to objectivize it are my fault.
- I've modified his constant names by prefixing them with a lower case c,
- and some of the types and typed constants have been incorporated into
- the TCalenderDef class
-
- For more calendar info, see The Calendar FAQ by Claus Tondering - a link
- is now maintained at http://www.merlyn.demon.co.uk/misctime.htm - and
- Peter Meyer's page.
-
- Julian Day Count is the number of days that have elapsed since Greenwich
- Mean Noon, Jan. 1, 4713 B.C.; MJD = JD - 2400000.5 . MJD is used because
- days start at midnight rather than noon.
-
- Here, the Julian Calendar is what it was intended to be; it only agrees
- with the Civil Calendar in 45 B.C., then from 8 A.D. to
- 1582/1752/whenever. Years are taken as Jan 1st .. Dec 31st, not always
- technically correct.
-
- RULES : G=Gregorian, J=Julian, C=Civil J-G :
- GJ No Year Zero (except for some Astronomers).
- G. Every 400 years contains Yrs400 days.
- G. Every 100 years contains Yrs100 days, unless including xx00/02/29.
- G. Every 4 years contains Yrs004 days, unless not including xxxx/02/29.
- .J Every 4 years contains Yrs004 days.
- GJ Every year contains Yrs001 days, unless including xxxx/02/29.
- G. Greg 1995/10/10 => MJD 50000.
- .J In Britain, 1752/09/03-13 were omitted;
- .J Julian 1752/09/02 preceded Gregorian 1752/09/14; therefore
- .J "Greg 1752/09/12 (MWS -160)" => MJD -38781 => Jul 1752/09/01.
- C Last Julian (Rome) = 1582/10/04; Last Julian (Britain) = 1752/09/02.
- .J N.B. Julian was in use from 45 BC, incorrectly until 8 or 12 AD.
-
- Only if Astro is set is the Year Zero included.
- ===================
- *)
-
- const
- cBaseYr = -32000 ;
- cYrs001 = 365 ;
- cYrs004 = cYrs001* 4 + 1 ;
- cYrs100 = cYrs004*25 - 1 ;
- cYrs400 = cYrs100* 4 + 1 ;
- cGregBias = ( { MJD +50000 => Greg 1995/10/10 }
- cYrs400*(((1995-cBaseYr) ) div 400) +
- cYrs100*(((1995-cBaseYr) mod 400) div 100) +
- cYrs004*(((1995-cBaseYr) mod 100) div 4) +
- cYrs001*(((1995-cBaseYr) mod 4) ) +
- 31+30+31+30+31+31+30 + 10 ) - 50000 ;
- cJulnBias = ( { MJD -38781 => Juln 1752/09/01 }
- cYrs004*(((1752-cBaseYr) ) div 4) +
- cYrs001*(((1752-cBaseYr) mod 4) ) +
- 31+30+31+30+31+31 + 1 ) + 38781 ;
-
- cBaseMo = 3 {Mar} ;
- cUltiMo = 14 {Feb} ;
- cSpecialMonthsArray : array [cBaseMo..Pred(cUltiMo)] of byte =
- (31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31) ;
-
- {
- type
- Calendar = (Gregorian, Julian, Civil) ;
- ChangeDate = (British, Romish, Other) ;
-
- CalN : array [Calendar] of string [9] =
- ('Gregorian', 'JulianCal', 'CivilDate') ;
- Bias : array [Gregorian..Julian] of longint = (GregBias, JulnBias) ;
- DiMo : array [BaseMo..Pred(UltiMo)] of byte =
- (31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31) ;
-
- //ChangeD : ChangeDate = British ;
- }
- cLastMJDEnglish = -38780 ; // LastBrit
- cLastMJDGreg = -100841 ; // LastRome
- //LastJulianMJD : array [ChangeDate] of longint = (LastBrit, LastRome, 0) ;
- //BRO : string [Succ(Ord(High(ChangeDate)))] = 'BRO' ;
-
- // Constants added
- cJDoffset = 2400000.5; // MJD + JD = Astronomer's Julian Day Number
- cMJD10Oct1995 = 50000;
- cMS10Oct1995 = 34982;
- cLowerTDateTime = -DateDelta; {found in systutils.pas}
- cUpperTDateTime = DateDelta; {693594 is value used in Delphi 3.02}
-
- {var
- LastJuln : array [ChangeDate] of record Y : integer ; M, D : byte end ;
- }
-
- implementation
-
-
- end.
-